package tr.edu.yildiz.ce.dap.apm;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

public class ProxyProperties {

	private static String PROXY_ADDRESS = "proxy.address";
	private static String PROXY_PORT = "proxy.port";
	private static String MCAST_ADDRESS = "proxy.mcast.address";
	private static String MCAST_PORT = "proxy.mcast.port";
	
	private static String ENCODING = "proxy.encoding";
	private static String PROXY_APPS = "proxy.apps.folder";
	private static String PROXY_AUTO_APPS = "proxy.auto.apps.folder";
	
	
	private static String CACHING_ENABLED = "proxy.caching.enabled";
	private static String PROXY_CACHE = "proxy.cache";
	
	private static String ID = "proxy.id";
	private static String USERNAME = "proxy.username";
	private static String PASSWORD = "proxy.password";
	
	private static String WS_URL = "proxy.wsurl";
	
	private static ProxyProperties instance;
	private Properties properties;
	
	public ProxyProperties() {
		String proxyPropPath = System.getProperty("proxy.properties");
		properties = new Properties();
		try {
			properties.load(new FileReader(new File(proxyPropPath)));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static ProxyProperties getInstance() {
		if (instance == null)
			instance= new ProxyProperties();
		return instance;
	}
	

	public String getProxyAddress() {
		return properties.getProperty(PROXY_ADDRESS);
	}

	public int getProxyPort() {
		return Integer.parseInt(properties.getProperty(PROXY_PORT));
	}

	public String getMcastAddress() {
		return properties.getProperty(MCAST_ADDRESS);
	}

	public int getMcastPort() {
		return Integer.parseInt(properties.getProperty(MCAST_PORT));
	}

	public String getEncoding() {
		return properties.getProperty(ENCODING);
	}
	

	public String getProxyApps() {
		return properties.getProperty(PROXY_APPS);
	}

	public String getProxyAutoApps() {
		return properties.getProperty(PROXY_AUTO_APPS);
	}

	public boolean isCachingEnabled() {
		return Boolean.parseBoolean(properties.getProperty(CACHING_ENABLED));
	}

	public String getProxyCache() {
		return properties.getProperty(PROXY_CACHE);
	}

	public long getId() {
		return Long.parseLong(properties.getProperty(ID));
	}
	
	public String getUsername() {
		return properties.getProperty(USERNAME);
	}
	
	public String getPassword() {
		return properties.getProperty(PASSWORD);
	}
	
	public String getWsUrl() {
		return properties.getProperty(WS_URL);
	}
}
